package com.cupcorn.lib.player;

import java.io.IOException;

import com.cupcorn.lib.game.GameEngine;
import com.cupcorn.lib.game.GameSound;
import com.cupcorn.lib.game.element.GameElementMusic;

public class PlayerSound
{
	GameElementMusic[]	gameElementMusic;
	public GameSound[]			sound;
	
	public PlayerSound(GameEngine engine, GameElementMusic[] gameElementMusic)
	{
		this.gameElementMusic = gameElementMusic;
		sound = new GameSound[gameElementMusic.length];
		
		try
		{
			for (int i = 0; i < gameElementMusic.length; i++)
			{
				sound[i] = new GameSound(engine, gameElementMusic[i]);
			}
		}
		catch (IOException e)
		{
			e.printStackTrace();
		}
	}
	
	public GameSound newSound(int index)
	{
		sound[index].play();
		return sound[index];
	}
	
	public void pauseAll()
	{
		for (int i = 0; i < gameElementMusic.length; i++)
		{
			sound[i].pause();
		}
	}
	
	public void resumeAll()
	{
		for (int i = 0; i < gameElementMusic.length; i++)
		{
			sound[i].resume();
		}
	}
}
